// 加密工具骨架

import JSEncrypt from "jsencrypt";

export function rsaEncryptBase64(plain: string, publicKeyPem: string): string {
  if (!publicKeyPem || !plain) return "";
  try {
    const encryptor = new JSEncrypt({ default_key_size: "2048" });
    encryptor.setPublicKey(publicKeyPem);
    const cipher = encryptor.encrypt(plain);
    return cipher || ""; // JSEncrypt 默认输出 base64 字符串
  } catch (e) {
    console.warn("rsaEncryptBase64 error:", e);
    return "";
  }
}

